<?php 
@$zid=$_REQUEST['zid']; 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>new document </title>
        <link rel="stylesheet" href="css\bootstrap.css">
        <script src="js/jquery-1.11.3.js">
        </script>
        <script src="js/bootstrap.js">
        </script>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" charset="UTF-8">
    </head>
    <body>
        <header>
            <nav class="navbar navbar-default" style="margin:auto">
                <div class="container">
                    <ul class="nav nav-tabs">
                        <li>
                            <a href="dcxt.php" class="btn btn-default" type="button" style="border:0px;margin:8px 0">
                                点餐系统
                            </a>
                        </li>
                        <li>
                            <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" style="border:0px;margin:8px 0;">
                                订单管理<span class="caret"></span>
                            </button>
                            <ul class="dropdown-menu" aria-labelledby="lx">
                                <li>
                                    <a href="list.php">订单列表</a>
                                </li>
                                <li>
                                    <a href="history.php">订单记录</a>
                                </li>
                            </ul>
                        </li>
                        <li>
                            <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" style="border:0px;margin:8px 0;">
                                菜品管理<span class="caret"></span>
                            </button>
                            <ul class="dropdown-menu" aria-labelledby="lx">
							
                                <li>
                                    <a href="dishappend.php">添加菜品</a>
                                </li>
                                <li>
                                    <a href="dishlist.php">菜品列表</a>
                                </li>
								 <li>
                                    <a href="dishtype.php">添加菜品类型</a>
                                </li> <li>
                                    <a href="typelist.php">菜品类型列表</a>
                                </li>
                            </ul>
                        </li>
                        <li>
                            <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" style="border:0px;margin:8px 0;">
                                餐桌管理<span class="caret"></span>
                            </button>
                            <ul class="dropdown-menu" aria-labelledby="lx">
                                <li>
                                    <a href="appendtable.php">添加餐桌</a>
                                </li>
                                <li>
                                    <a href="tablelist.php">餐桌列表</a>
                                </li>
                            </ul>
                        </li>
                        <li>
                            <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" style="border:0px;margin:8px 0;">
                                登录管理<span class="caret"></span>
                            </button>
                            <ul class="dropdown-menu" aria-labelledby="lx">
                                <li>
                                    <a href="modifier.php">修改登陆信息</a>
                                </li>
                                <li>
                                    <a href="#">退出登录</a>
                                </li>
                            </ul>
                        </li>
                    </ul>
                </div>
            </nav>
        </header>
        <div class="container" style="width:100%" id="zhuye">
        <div class="row">
            <div class="col-xs-3">
                <div class="modal-dialog" style="width:100%">
                    <div class="modal-content">
                        <div class="modal-header">
                            <form class="form">
                                <div class="form-group">
                                    <div class="input-group" style="margin:auto">
                                        <input type="text" class="form-control" placeholder="桌号" name="tablename"/>
                                        <div class="input-group-btn">
                                            <button class="btn btn-default" style="height:34px" type="submit">
                                                <span class="glyphicon glyphicon-search"></span>
                                            </button>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <div class="modal-body">
                            <div class="table text-center">
							<?php 
								@$tablename=$_REQUEST['tablename'];
								if(empty($tablename)){
									$pdo=new PDO('mysql:dbname=test;charset=utf8','root'); 
									$sel=$pdo->prepare('select * from number');
									$sel->execute(array());
									$b=$sel->fetchAll(PDO::FETCH_NAMED);
									foreach($b as $c){
							?>
								<a href="dcxt.php?zid=<?php echo $c['id'] ?>" class="list-group-item">
								<?php echo $c['tablename'] ?></a>
								<?php } ?><?php } else { 
									$pdo=new PDO('mysql:dbname=test;charset=utf8','root'); 
									$sel=$pdo->prepare('select * from number where tablename like :tablename'); 
									$sel->execute(array('tablename'=>'%'.$tablename.'%'));
									$bc=$sel->fetchAll(PDO::FETCH_NAMED);
									foreach($bc as $cb){
									?>
									<a href="dcxt.php?zid=<?php echo $cb['id'] ?>" class="list-group-item">
									<?php echo $cb['tablename'] ?></a>
									<?php } 
										}	?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xs-9">
                <div class="panel panel-default">
                    <div class="panel-heading">
						<div class="row">
							<div class="col-xs-9">
								<h4>
									<span class="glyphicon glyphicon-ok">
									<?php
										$pdo=new PDO('mysql:dbname=test;charset=utf8','root'); 
										$sel=$pdo->prepare('select * from number where id=:id');
										$sel->execute(array('id'=>$zid));
										$z=$sel->fetch(PDO::FETCH_NAMED);
										echo $z['tablename'];
									?>-已选</span>
								</h4>
							</div>
							<div class="col-xs-3 active">
								<a href="#" class="btn btn-success pull-right">
									已选
									<span class="badge">32元</span>
								</a>
							</div>
						</div>
                    </div>
                  <div class="panel-body">
                     <div class="row">
                           
                    </div>
                </div>
				<div class="panel panel-default">
                        <div class="panel-heading">
                            <div class="row">
                                <div class="col-xs-8">
                                	<a href="#" class="btn btn-link">
                                		 <span class="glyphicon glyphicon-th-list">可选菜品</span>
                                	</a>
                                   
                                </div>
                                <div class="col-xs-4">
									<form class="form">
										<div class="form-group">
											<div class="input-group" style="margin:auto">
												<input type="text" class="form-control" style="width: 167px;" placeholder="菜名" name="dishname1">
												</input>
												<select class="form-control" style="width:100px" name="type1">
													<option>全部</option>
												   <?php
															$pdo=new PDO('mysql:dbname=test;charset=utf8','root'); 
															$sel=$pdo->prepare('select * from dishtype');
															$sel->execute(array());
															$d=$sel->fetchAll(PDO::FETCH_NAMED);
															foreach($d as $e){
														?>
															<option> <?php echo $e['dishtype'] ?> </option>
														<?php } ?>			
												</select>
												<span class="input-group-btn">
													<button class="btn btn-default" type="button submit">
														<span class="glyphicon glyphicon-search"></span>
														&nbsp;
													</button>
												</span>
											</div>
										</div>
									</form>
                                </div>
                            </div>
                        </div>
                        <div class="panel-body">
                            <div class="row">
                            <?php
								@$dishname1=$_REQUEST['dishname1'];
								@$type1=$_REQUEST['type1'];
								if(empty($dishname1) && (empty($type1) || $type1 == "全部")){
                            	$pdo=new PDO('mysql:dbname=test;charset=utf8','root'); 
								$sel=$pdo->prepare('select * from menu');
								$sel->execute(array());
								$x=$sel->fetchAll(PDO::FETCH_NAMED);
								foreach($x as $y){
							?>
							
                                <div class="col-xs-3">
                                    <div class="thumbnail">
                                        <img src="<?php echo "dish/".$y['url'] ?>" alt="<?php echo $y['name'] ?>" class="img-rounded">
                                        </img>
                                        <div class="caption">
                                        	<p>
                                    	 	<a href="#" class="btn btn-link" role="button" style="font-size:large;">
                                    	 	<?php echo $y['name'] ?></a> 
											<a href="#" class="btn btn-primary btn-link" role="button"  style="font-size:large;">
											<?php echo $y['value'] ?>元</a>
										</p>
                                        </div>
                                    </div>
								</div>
                                <?php } } elseif (empty($dishname1) && (!empty($type1) || $type1 != "全部")){  
									$pdo=new PDO('mysql:dbname=test;charset=utf8','root'); 
									$sel=$pdo->prepare('select * from menu where dishtype=:dishtype');
									$sel->execute(array('dishtype'=>$type1));
									$xy=$sel->fetchAll(PDO::FETCH_NAMED);
									foreach($xy as $yx){
										?>
								<div class="col-xs-3">
									<div class="thumbnail">
                                        <img src="<?php echo "dish/".$yx['url'] ?>" alt="<?php echo $yx['name'] ?>" class="img-rounded">
                                        </img>
                                        <div class="caption">
                                        	<p>
                                    	 	<a href="#" class="btn btn-link" role="button" style="font-size:large;">
                                    	 	<?php echo $yx['name'] ?></a> 
											<a href="#" class="btn btn-primary btn-link" role="button"  style="font-size:large;">
											<?php echo $yx['value'] ?>元</a>
										</p>
                                        </div>
                                    </div>
								</div>
								<?php } } elseif (!empty($dishname1) && (empty($type1) || $type1 == "全部")){
											$pdo=new PDO('mysql:dbname=test;charset=utf8','root'); 
											$sel=$pdo->prepare('select * from menu where name like :name');
											$sel->execute(array('name'=>'%'.$dishname1.'%'));
											$xyz=$sel->fetchAll(PDO::FETCH_NAMED);
											foreach($xyz as $yxz){
											?>
								<div class="col-xs-3">
									<div class="thumbnail">
                                        <img src="<?php echo "dish/".$yxz['url'] ?>" alt="<?php echo $yxz['name'] ?>" class="img-rounded">
                                        </img>
                                        <div class="caption">
                                        	<p>
                                    	 	<a href="#" class="btn btn-link" role="button" style="font-size:large;">
                                    	 	<?php echo $yxz['name'] ?></a> 
											<a href="#" class="btn btn-primary btn-link" role="button"  style="font-size:large;">
											<?php echo $yxz['value'] ?>元</a>
										</p>
                                        </div>
                                    </div>
								</div>
								<?php } } elseif (!empty($dishname1) && (!empty($type1) || $type1 != "全部")){ 
											$pdo=new PDO('mysql:dbname=test;charset=utf8','root'); 
											$sel=$pdo->prepare('select * from menu where name like :name');
											$sel1=$pdo->prepare('select * from menu where dishtype=:type1');
											$sel->execute(array('name'=>'%'.$dishname1.'%'));
											$sel1->execute(array('type1'=>$type1));
											$xzy=$sel->fetchAll(PDO::FETCH_NAMED);
											$xzy1=$sel1->fetchAll(PDO::FETCH_NAMED);
											if(!empty($xzy) && !empty($xzy1)){
												foreach($xzy as $yzx){
													$yzx1=array($yzx['id']);}
												foreach($xzy1 as $yzx2){
													$yzx3=array($yzx2['id']);}
													}
												global $yzx1,$yzx1;
												foreach($xzy as $yzx4){
													if($yzx1 == $yzx3){
													while($yzx4['id'] == $yzx3){

											?>
								<div class="col-xs-3">
									<div class="thumbnail">
                                        <img src="<?php echo "dish/".$yzx4['url'] ?>" alt="<?php echo $yzx4['name'] ?>" class="img-rounded">
                                        </img>
                                        <div class="caption">
                                        	<p>
                                    	 	<a href="#" class="btn btn-link" role="button" style="font-size:large;">
                                    	 	<?php echo $yzx4['name'] ?></a> 
											<a href="#" class="btn btn-primary btn-link" role="button"  style="font-size:large;">
											<?php echo $yzx4['value'] ?>元</a>
										</p>
                                        </div>
                                    </div>
								</div>
								<?php } } } } ?>
                            </div>
                        </div>
                    </div>
            </div>
        </div>
		
    </body>
</html>
